package com.itheima.app.config;

import com.itheima.app.interceptor.TokenInterceptor;
import com.itheima.app.interceptor.UserStateInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    TokenInterceptor tokenInterceptor;
    @Autowired
    UserStateInterceptor userStateInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")//拦截所有的路径
                .excludePathPatterns("/user/loginVerification","/user/login");//放行和登陆注册相关的操作
        registry.addInterceptor(userStateInterceptor)
                .addPathPatterns("/comments","/smallVideos/{publishId}/comments","/peachblossom","/movements")//拦截所有的路径
                .excludePathPatterns("/user/loginVerification","/user/login");//放行和登陆注册相关的操作
    }
}
